package cn.italobing.mybatis.text;

import java.io.IOException;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import cn.itlaobing.entity.Account;
import cn.itlaobing.entity.LoginLog;
import cn.itlaobing.mapper.AccountMapper;

public class AccountMapperText extends BaseMapperText {
	
	
	@Test
	public void testFindById() throws IOException {
		SqlSession sqlSession = sqlSession();

		try {
			AccountMapper accountMapper = sqlSession.getMapper(AccountMapper.class);
			Account account = accountMapper.selectByPrimaryKey(1);

			log.info(account.getStudent().getName());
		} finally {
			sqlSession.close();
		}
	}
	
	
	@Test
	public void testFindByIdLoginLog() throws IOException {
		SqlSession sqlSession = sqlSession();

		try {
			AccountMapper accountMapper = sqlSession.getMapper(AccountMapper.class);
			Account account = accountMapper.selectByPrimaryKeyLoginLog(1);

			for (LoginLog loginLog : account.getLoginLogs()) {
				log.info(loginLog.getLoginAt());
			}
		} finally {
			sqlSession.close();
		}
	}
}
